package com.m.IO.Chars;

import java.io.*;

/**
 * BufferedWriter中并没有自动换行的功能，可以使用newLind()进行换行
 * newLind()加入一个换行符
 *
 * BufferedReader.readLine()每次读取一行，可以利用while(true){}，进行内容的输出
 * @author Mc.Chai
 * @program: Java基础
 * @create 2021-11-22-17:03 17:03
 */
public class TestBuffered {
    public static void main(String[] args) throws IOException {
        FileWriter fileWriter=new FileWriter("writer.txt");
        BufferedWriter bufferedWriter=new BufferedWriter(fileWriter);
        bufferedWriter.write("abc");
        bufferedWriter.write("不会换行");
        bufferedWriter.newLine();           //进行强制换行
        bufferedWriter.write("abc");
        bufferedWriter.close();
        FileReader fileReader=new FileReader("writer.txt");
        BufferedReader bufferedReader=new BufferedReader(fileReader);


        while (true){
            String s=bufferedReader.readLine();
            if (s==null) break;
            System.out.println(s);
        }
    }
}
